{extend name="default/template/base_index" /}


{block name="area_header"}

<link type="text/css" rel="stylesheet" href="__CDN__/jquery-uploadify/3.2.1/uploadify.css"/>
<script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
{/block}

{block name="area_body"}
<div class="admin-main container-fluid">
    <div class="admin-main-content">
        <!-- form -->
        <form class="form-horizontal well validateForm">
            <fieldset>
                <legend>
                    设备更新<span class="help-block">上传更新包，则更新为更新包版本，如果不上传，则更新到系统中现有的最新版，上传版本不会影响现有的系统最新版本</span></legend>
                <div class="form-group">
                    <label class="col-md-2 col-lg-2 control-label">设备did</label>
                    <div class="col-md-10 col-lg-10">
                        <input type="text" value="" class="required form-control input-short" name="did"
                               placeholder="请输入设备did">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 col-lg-2 control-label">更新包</label>
                    <div class="col-md-10 col-lg-10"><a href="javascript:void(0);" id="upload_file"><i
                            class="fa fa-upload"></i>上传</a>
                        <div class="help-block j_upload"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 col-lg-2 control-label"></label>
                    <div class="col-md-10 col-lg-10">
                        <input type="hidden" class="j_bytes required form-control input-normal" name="bytes"
                               disabled="disabled" value="512" placeholder="版本大小">
                    </div>
                </div>
                <div class="form-group hide">
                    <label class="col-md-2 col-lg-2 control-label">url</label>
                    <div class="col-md-10 col-lg-10">
                        <input type="text" class="j_url required form-control input-normal" name="url"
                               placeholder="更新包路径">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 col-lg-2 control-label">&nbsp;</label>
                    <div class="col-lg-10 col-md-10">
                        <a target-form="validateForm" class="ajax-post btn btn-primary"
                           href="{:url('DeviceUpdate/index')}" autofocus="autofocus"><i class="fa fa-save"></i>确定更新</a>
                    </div>
                </div>
            </fieldset>
        </form>
        <!-- form -->
    </div>

</div>
{/block}

{block name="area_footer"}
<script>
    $(function () {
        $("#upload_file").uploadify({
            'buttonClass': 'btn btn-primary btn-sm',
            "height": "30px",
            "swf": "__UPLOAD__/jquery-uploadify/3.2.1/uploadify.swf",
            "fileObjName": "wxshop", //wxshop
            "buttonText": "<i class='fa fa-upload'></i>本地上传",
            "uploader": "{:url('DeviceUpdate/upload_file',array('session_id'=>session_id()))}",
            "width": 120,
            'removeTimeout': 1,
            'fileTypeExts': '*.bin; *.doc;',
            "onUploadSuccess": uploadPicture
        });


        function uploadPicture(file, data) {
            var data = $.parseJSON(data);
            if (data.status) {
                $(".j_bytes").val(data.size);
                $(".j_url").val(data.id);
                $(".j_upload").text("上传成功");
            } else {
                $.scojs_message(data.info, $.scojs_message.TYPE_OK);
            }
        }
    })
</script>
{/block}